package kaizen;

// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 07/02/2013 05:27:42 p.m.
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ExSqrServlet.java
import java.io.*;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.SingleThreadModel;
import javax.servlet.http.*;
import kaizen.jdbc.DbAppUnivC;
import kaizen.nomweb.*;

public class ExSqrServlet extends HttpServlet
        implements SingleThreadModel {

    public ExSqrServlet() {
    }

    public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws IOException, ServletException {
        httpservletresponse.setContentType("text/html");
        out = httpservletresponse.getWriter();
        String s = httpservletrequest.getParameter("sPid");
        String s1 = httpservletrequest.getParameter("escenario");
        String s2 = httpservletrequest.getParameter("reporte");
        String s3 = httpservletrequest.getParameter("usuario");
        String s4 = httpservletrequest.getParameter("pwd");
        String s5 = httpservletrequest.getParameter("salidaEsp");
        String s6 = httpservletrequest.getParameter("arch_prop");
        if (s2 != null) {
            s2.trim();
        }
        Properties properties = utilerias.loadProperties(s6);
        String s7 = properties.getProperty("sqr_dirRepSalida");
        String s8 = properties.getProperty("sqr_dirRep");
        String s9 = properties.getProperty("sqr_progSqr");
        String s10 = s3;
        String s11 = s4;
        String s12 = properties.getProperty("sqr_bd");
        String s13 = properties.getProperty("sqr_imports");
        String s14 = properties.getProperty("sqr_tipoSalida");
        String s15 = properties.getProperty("sistema_operativo");
        String s16 = properties.getProperty("sqr_tipo_bd");
        String s17 = s3 + " " + s1 + " " + s;
        String s18 = properties.getProperty("sqr_WebDir");
        String s19 = properties.getProperty("sqr_dirRepSalidaCrear");
        String s20 = "select parametros from procesos where pid = " + s;
        s17 = utilerias.valorSqlUni(s20);
        boolean flag = false;
        if (s15.trim().equals("unix")) {
            flag = true;
        }
        boolean flag1 = false;
        if (s16.trim().equals("oracle")) {
            flag1 = true;
        }
        Object obj = null;
        try {
            String s21 = "";
            String s22 = "";
            String s23 = "";
            String s24 = "";
            String s25 = "";
            String s26 = "";
            s22 = "SELECT PASI_PARAMETRO1";
            s22 = s22 + " FROM SCC_PARAMETROS_SISTEMA";
            s22 = s22 + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s22 = s22 + " AND    PASI_PLANTA_BODEGA   = '001'";
            s22 = s22 + " AND    PASI_PARAMETRO       = 83";
            s22 = s22 + " AND    PASI_CONSECUTIVO     = 1";
            String s27 = utilerias.valorSqlUni(s22);
            s23 = "SELECT REPLACE(PASI_PARAMETRO1, '";
            s23 = s23 + "\"','')";
            s23 = s23 + " FROM SCC_PARAMETROS_SISTEMA";
            s23 = s23 + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s23 = s23 + " AND    PASI_PLANTA_BODEGA   = '001'";
            s23 = s23 + " AND    PASI_PARAMETRO       = 21";
            s23 = s23 + " AND    PASI_CONSECUTIVO     = 4";
            String s28 = utilerias.valorSqlUni(s23);
            s24 = "SELECT PASI_PARAMETRO1";
            s24 = s24 + " FROM SCC_PARAMETROS_SISTEMA";
            s24 = s24 + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s24 = s24 + " AND    PASI_PLANTA_BODEGA   = '001'";
            s24 = s24 + " AND    PASI_PARAMETRO       = 21";
            s24 = s24 + " AND    PASI_CONSECUTIVO     = 5";
            String s29 = utilerias.valorSqlUni(s24);
            s25 = "SELECT PASI_PARAMETRO1";
            s25 = s25 + " FROM SCC_PARAMETROS_SISTEMA";
            s25 = s25 + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s25 = s25 + " AND    PASI_PLANTA_BODEGA   = '001'";
            s25 = s25 + " AND    PASI_PARAMETRO       = 21";
            s25 = s25 + " AND    PASI_CONSECUTIVO     = 7";
            String s30 = utilerias.valorSqlUni(s25);
            s26 = "SELECT PASI_PARAMETRO2";
            s26 = s26 + " FROM SCC_PARAMETROS_SISTEMA";
            s26 = s26 + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s26 = s26 + " AND    PASI_PLANTA_BODEGA   = '001'";
            s26 = s26 + " AND    PASI_PARAMETRO       = 21";
            s26 = s26 + " AND    PASI_CONSECUTIVO     = 6";
            String s31 = utilerias.valorSqlUni(s26);
            s21 = s28 + " " + s29 + s2;
            if (flag1) {
                s21 = s21 + " " + s10 + "/" + s11 + "@" + s27;
            } else {
                s21 = s21 + " " + s12 + "/" + s10 + "/" + s11;
            }
            String saux = "SELECT PASI_PARAMETRO1";
            saux = saux + " FROM SCC_PARAMETROS_SISTEMA";
            saux = saux + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            saux = saux + " AND    PASI_PLANTA_BODEGA   = '001'";
            saux = saux + " AND    PASI_PARAMETRO       = 1065";
            String sExcel = utilerias.valorSqlUni(saux);
            String s26aux = "SELECT 1";
            s26aux = s26aux + " FROM SCC_PARAMETROS_SISTEMA";
            s26aux = s26aux + " WHERE  PASI_SIST_CLAVE      = 'SCC'";
            s26aux = s26aux + " AND    PASI_PLANTA_BODEGA   = '001'";
            s26aux = s26aux + " AND    PASI_PARAMETRO       = 1060";
            s26aux = s26aux + " AND    PASI_PARAMETRO1     = '" + s2 + "'";
            String s31aux = utilerias.valorSqlUni(s26aux);
            boolean bRepoExcel = false;
            if (s31aux == null) {
                s21 = s21 + " " + s31;
            } else {
                bRepoExcel = true;
                s21 = s21 + " " + sExcel;
            }
            s21 = s21 + " -F" + s7;
            String s32 = utilerias.fechaHoy("dd_MM_yyyy_HH_mm_ss");
            if (bRepoExcel) {
                s21 = s21 + s2 + "_" + s32 + ".csv";
            } else {
                s21 = s21 + s2 + "_" + s32 + ".pdf";
            }
            s21 = s21 + " " + s14;
            s21 = s21 + " " + s17;
            String s33 = properties.getProperty("log_ExecSqr");
            Historico historico = new Historico(s33, true);
            historico.agregar(s21);
            historico.cerrar();
            String s34 = "";
            String s35 = "";
            String s36 = "";
            s35 = s2 + "_" + s32;
            s36 = "S";
            s34 = "INSERT INTO SCC_REPORTES(REPO_CLAVE, REPO_COMANDO, REPO_STATUS) ";
            s34 = s34 + "VALUES (";
            s34 = s34 + "'" + s35 + "','" + s21 + "','" + s36 + "')";
            DbAppUnivC.execStatement(s34);
            for (String s37 = "S"; !s37.equals("E") && !s37.equals("G");) {
                String s38 = "SELECT repo_status";
                s38 = s38 + "\tFROM scc_reportes";
                s38 = s38 + " WHERE repo_clave = '" + s35 + "'";
                s37 = utilerias.valorSqlUni(s38);
                if (s37.equals("E") || s37.equals("G")) {
                    String s40 = "DELETE scc_reportes";
                    s40 = s40 + " WHERE repo_clave = '" + s35 + "'";
                    s40 = s40 + " AND REPO_STATUS IN ('E','G')";
                    DbAppUnivC.execStatement(s40);
                }
                try {
                    Thread.sleep(10000L);
                } catch (InterruptedException interruptedexception) {
                    System.out.println("Sleep Interrupted");
                }
            }

            String s39 = "";
            if (bRepoExcel) {
                s39 = s35 + ".csv";
            } else {
                s39 = s35 + "_frm.htm";
            }
            if (s5 == null) {
                s5 = "";
            }
            if (s5.trim().length() > 0) {
                if (s5.startsWith("con_parametros=")) {
                    s5 = utilerias.generaValDer("con_parametros=", s5);
                    String s41 = properties.getProperty("host");
                    String s43 = s18 + s5;
                    String s44 = templates.generaPlantilla(s43, s41);
                    s44 = utilerias.replaceString1(s44, "--nombre_archivo--", s18 + s39);
                    s44 = utilerias.replaceString1(s44, "--pid--", s);
                    out.println(s44);
                    return;
                }
                s5 = utilerias.replaceString(s5.trim(), "[pid]", s);
                s39 = s5;
            }
            String s42 = s18 + s39;
            s33 = properties.getProperty("log_ExecSqr");
            out.println("redirect27" + s42);
        } catch (IOException ioexception) {
            System.out.println("Existio un error al correr el servlet: " + ioexception);
        }


        DbAppUnivC.closeConnJSP();   //AQUI 
    }

    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws IOException, ServletException {
        doGet(httpservletrequest, httpservletresponse);
    }
    PrintWriter out;
}